<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="../common/NavigationLeft.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>固定资产管理系统</title>
</head>
<body>

	<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
	<h2 class="page-header"><a href="listAsset.action">返回资产列表</a></h2>
		<div class="form-horizontal">
			<div class="form-group form-inline">
				<label class="col-sm-2 control-label">资产编号：</label> <span
					class="col-sm-4 control-label" style="text-align: left">${assetWeb.equipIdentifier}
				</span>
			</div>
			<div class="form-group form-inline">
				<label class="col-sm-2 control-label">IT编号：</label> <span
					class="col-sm-4 control-label" style="text-align: left">${assetWeb.itCode}
				</span>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">设备类别：</label> <span
					class="col-sm-4 control-label" style="text-align: left">${assetWeb.equipGenre}
				</span>
			</div>
			<div class="form-group form-inline">
				<label class="col-sm-2 control-label">设备名称：</label> <span
					class="col-sm-4 control-label" style="text-align: left">${assetWeb.equipName}
				</span>
			</div>
			<div class="form-group form-inline">
				<label class="col-sm-2 control-label">设备品牌：</label> <span
					class="col-sm-4 control-label" style="text-align: left">${assetWeb.equipBrand}
				</span>
			</div>
			<div class="form-group form-inline">
				<label class="col-sm-2 control-label">设备型号：</label> <span
					class="col-sm-4 control-label" style="text-align: left">${assetWeb.equipModel}
				</span>
			</div>

			<div class="form-group">
				<label class="col-sm-2 control-label">使用人员：</label> <span
					class="col-sm-4 control-label" style="text-align: left">${assetWeb.usePerson}
				</span>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">使用部门：</label> <span
					class="col-sm-4 control-label" style="text-align: left">${assetWeb.useDepart}
				</span>
				<%-- <c:forEach var="item" items="${departmentList}">                 
                    <c:if test="${item.id == asset.useDepart}">
                        <span class="col-sm-4 control-label" style="text-align:left"> ${item.name}</span>
                    </c:if>                                        
                </c:forEach>  --%>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">设备存放地点：</label> <span
					class="col-sm-4 control-label" style="text-align: left">${assetWeb.equipLocation}
				</span>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">设备归属地点：</label> <span
					class="col-sm-4 control-label" style="text-align: left">${assetWeb.equipAttach}
				</span>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">资产状态：</label> <span
					class="col-sm-4 control-label" style="text-align: left">${assetWeb.status}
				</span>
			</div>
		<%-- 	<div class="form-group">
				<label class="col-sm-2 control-label">资产配置：</label> <span
					class="col-sm-4 control-label" style="text-align: left">${assetWeb.assetAllocation}
				</span>
			</div> --%>
			<div class="form-group form-inline">
				<label class="col-sm-2 control-label">购买日期：</label> <span
					class="col-sm-4 control-label" style="text-align: left">
					${assetWeb.buyTime} </span>
			</div>
			<div class="form-group form-inline">
				<label class="col-sm-2 control-label">分配日期：</label> <span
					class="col-sm-4 control-label" style="text-align: left">
					${assetWeb.assignTime} </span>
			</div>
			<div class="form-group form-inline">
				<label class="col-sm-2 control-label">领用日期：</label> <span
					class="col-sm-4 control-label" style="text-align: left">
					${assetWeb.receiveTime} </span>
			</div>
			<div class="form-group form-inline">
				<label class="col-sm-2 control-label">最后修改人：</label> <span
					class="col-sm-4 control-label" style="text-align: left">
					${assetWeb.lastUser} </span>
			</div>
			<div class="form-group form-inline">
				<label class="col-sm-2 control-label">最后修改时间：</label> <span
					class="col-sm-4 control-label" style="text-align: left">
					${assetWeb.modifyTime} </span>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">备注：</label> <span
					class="col-sm-4 control-label" style="text-align: left">${assetWeb.remarks}
				</span>
			</div>
		</div>
		<div>使用记录:</div>
	<table id="listTable"
		class="table table-bordered table-striped table-hover dataTable no-footer dtr-inline" cellspacing="0" >
		<thead>
			<tr>
				<th>使用人姓名</th>
				<th>使用人编号</th>
				<th>分配日期</th>
				<th>领用日期</th>
				<th>归还日期</th>
				<th>设备使用状况</th>
			</tr>
		</thead>
	</table>
	</div>
	<input id="assetId" type="hidden" value="${assetWeb.id}">
</body>
<script type="text/javascript">


$(function(){
	var table = "";
	initTable();
	
	//初始化表格的方法，上面的事件中调用该方法
	function initTable() {
		$.fn.dataTable.ext.errMode = function(s,h,m){
            layer.alert('数据加载失败');
        }
		var assetId = $("#assetId").val();
		 table = $('#listTable').DataTable( {
			 "destroy" : true,
			"paging" : true,
			"lengthChange" : true,
			"searching" : false,
			"ordering" : false,
			"info" : true,
			"autoWidth" : false,
			"Filter" : false,
			responsive : true,
			"pagingType" : "full_numbers",
			"dom" : 'rtilp',
			"language" : {
				"url" : "/static/js/datatables/jquery.dataTables.zh"
			},
	        "processing": true,
	        "serverSide": true,
	        "ajax": {
	   	          type: 'POST',  
	   	          url: 'ajax_listAllHistoryData.action',
	   	          data: {"id":assetId},
	   	          timeout:60000  
	   	      },
	        "columns" : [
							{
								"data" : function(data) {
									if(data.usePerson != null){
										return data.usePerson;
									}else{
										return "--";
									}
								}
							},
							{
								"data" : function(data) {
									if(data.userCode != null){
										return data.userCode;
									}else{
										return "--";
									}
								}
							},
							{
								"data" : function(data) {
									if(data.assignTime != null){
										/* var now = new Date(data.assignTime);
										var nowStr = now.format("yyyy-MM-dd hh:mm:ss"); */
										return data.assignTime;
									}else{
										return "--";
									}
								}
							},
							{
								"data" : function(data) {
									if(data.receiveTime != null){
										return data.receiveTime;
									}else{
										return "--";
									}
								}
							},
							{
								"data" : function(data) {
									if(data.revertTime != null){
										return data.revertTime;
									}else{
										return "--";
									}
								}
							},	
							{
								"data" : function(data) {
									if(data.equipState != null){
										return data.equipState;
									}else{
										return "--";
									}
								}
							}
					]
               });
		return table;
	}
}); 
	
	//对Date的扩展，将Date转化为指定格式的String
	Date.prototype.format = function(format){
		var o = {
		"M+" : this.getMonth()+1, //month
		"d+" : this.getDate(), //day
		"h+" : this.getHours(), //hour
		"m+" : this.getMinutes(), //minute
		"s+" : this.getSeconds(), //second
		"q+" : Math.floor((this.getMonth()+3)/3), //quarter 季度
		"S" : this.getMilliseconds() //millisecond 毫秒
		}

		if(/(y+)/.test(format)) {
		format = format.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
		}

		for(var k in o) {
			if(new RegExp("("+ k +")").test(format)) {
				format = format.replace(RegExp.$1, RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length));
			}
		}
		return format;
	} 
</script>
</html>